package com.xiaoming.moj.judge;

import com.xiaoming.moj.judge.strategy.DefaultStrategy;
import com.xiaoming.moj.judge.strategy.JavaLanguageJudgeStrategy;
import com.xiaoming.moj.judge.strategy.JudgeContext;
import com.xiaoming.moj.judge.strategy.JudgeStrategy;
import com.xiaoming.moj.model.dto.questionsubmit.JudgeInfo;
import com.xiaoming.moj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

@Service
public class JudgeManager {
    JudgeInfo doJudge(JudgeContext judgeContext)
    {
        QuestionSubmit questionSubmit=judgeContext.getQuestionSubmit();
        String language=questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy=new DefaultStrategy();
        if(language.equals("java"))
        {
             judgeStrategy=new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
